import tkinter as tk
from tkinter import ttk
from typing import Callable


class SearchBar(ttk.Frame):
    def __init__(self, master, search_callback: Callable[[str], None]):
        super().__init__(master)

        self.entry = ttk.Entry(self)
        self.entry.pack(side=tk.LEFT, fill=tk.X, expand=True)

        self.button = ttk.Button(
            self, text="搜索", command=lambda: search_callback(self.entry.get())
        )
        self.button.pack(side=tk.LEFT, padx=6)
        self.search_callback = search_callback


if __name__ == "__main__":
    root = tk.Tk()
    search_bar = SearchBar(root)
    search_bar.pack(fill=tk.X)
    root.mainloop()
